package com.mDigitalHealth.http;

import java.util.LinkedHashMap;
import java.util.Map;

import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;

public class RegRequest {

	private String imei;

	public RegRequest() {
		imei = "";
	}

	public RegRequest(String imei) {
		this.imei = imei;
	}

	public String getImei() {
		return imei;
	}

	public void setImei(String imei) {
		this.imei = imei;
	}

	public String encode() {
		try {
			LinkedHashMap map = new LinkedHashMap();

			map.put("imei", this.imei);

			return JSONValue.toJSONString(map);
		} catch (Exception e) {
		}
		return null;
	}

	public int decode(String strCode) {
		try {
			if (strCode == null) {
				return -1;
			}
			JSONParser parser = new JSONParser();
			Map map = (Map) parser.parse(strCode);
			this.imei = ((String) map.get("imei"));

			return 1;
		} catch (Exception e) {
		}
		return -1;
	}
}
